import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
import _createClass from "@babel/runtime/helpers/esm/createClass";
import _inherits from "@babel/runtime/helpers/esm/inherits";
import _createSuper from "@babel/runtime/helpers/esm/createSuper";
import _applyDecoratedDescriptor from "@babel/runtime/helpers/esm/applyDecoratedDescriptor";
var _excluded = ["form", "btnKey", "btnProps", "btnConfig", "index", "title"];

var _dec, _dec2, _dec3, _class, _class2;

/**
 * BtnTitleEditModal.js
 * @date 2018-12-19

 */
import React from 'react';
import { Col, Form, Input, Modal, Row } from 'antd';
import { Bind } from 'lodash-decorators';
import intl from 'utils/intl';
var formItemLayout = {
  labelCol: {
    span: 6
  },
  wrapperCol: {
    span: 16
  }
};
var BtnTitleEditModal = (_dec = Form.create({
  fieldNameProp: null
}), _dec2 = Bind(), _dec3 = Bind(), _dec(_class = (_class2 = /*#__PURE__*/function (_React$Component) {
  _inherits(BtnTitleEditModal, _React$Component);

  var _super = _createSuper(BtnTitleEditModal);

  function BtnTitleEditModal() {
    _classCallCheck(this, BtnTitleEditModal);

    return _super.apply(this, arguments);
  }

  _createClass(BtnTitleEditModal, [{
    key: "render",
    value: function render() {
      var _this$props = this.props,
          form = _this$props.form,
          btnKey = _this$props.btnKey,
          btnProps = _this$props.btnProps,
          btnConfig = _this$props.btnConfig,
          index = _this$props.index,
          title = _this$props.title,
          modalProps = _objectWithoutProperties(_this$props, _excluded);

      return /*#__PURE__*/React.createElement(Modal, Object.assign({}, modalProps, {
        width: 520,
        title: "\u6309\u94AE\u540D\u79F0\u7F16\u8F91",
        onOk: this.handleSave,
        onCancel: this.handleCancel
      }), /*#__PURE__*/React.createElement(Form, null, /*#__PURE__*/React.createElement(Row, null, /*#__PURE__*/React.createElement(Col, null, /*#__PURE__*/React.createElement(Form.Item, Object.assign({}, formItemLayout, {
        label: "\u6309\u94AE\u540D\u79F0"
      }), form.getFieldDecorator('title', {
        initialValue: title,
        rules: [{
          required: true,
          message: intl.get('cpaas.common.validation.notNull', {
            name: '按钮名称'
          })
        }]
      })( /*#__PURE__*/React.createElement(Input, null)))))));
    }
  }, {
    key: "handleSave",
    value: function handleSave() {
      var _this = this;

      var form = this.props.form;
      form.validateFields(['title'], function (err) {
        var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
            title = _ref.title;

        if (!err) {
          var onSave = _this.props.onSave;
          onSave(title);
        }
      });
    }
  }, {
    key: "handleCancel",
    value: function handleCancel() {
      var onCancel = this.props.onCancel;
      onCancel();
    }
  }]);

  return BtnTitleEditModal;
}(React.Component), (_applyDecoratedDescriptor(_class2.prototype, "handleSave", [_dec2], Object.getOwnPropertyDescriptor(_class2.prototype, "handleSave"), _class2.prototype), _applyDecoratedDescriptor(_class2.prototype, "handleCancel", [_dec3], Object.getOwnPropertyDescriptor(_class2.prototype, "handleCancel"), _class2.prototype)), _class2)) || _class);
export { BtnTitleEditModal as default };